$(function () {
    //======================
    //======设置查询条件========
    //======================

    //搜索按钮
    $("#btn_ykbb_search").click(function () {
        $(grid).datagrid({
            queryParams:{
                gysName:$("#ykbb_gys").val(),
                htbm:$("#ykbb_htbm").val()
            }});
    });


//======================
//========统计列表========
//======================
    var columns = [
        [
            {field:'HTBM', title:'采购合同号', width:150, align:'center'},
            {field:'QC', title:'供应商', width:150, align:'center'},
            {field:'cgje', title:'采购金额', width:150, formatter:function (v, r, i) {
                return formatMoneyFourWei(v);
            }, align:'right'},
            {field:'kcje', title:'库存金额', width:150, formatter:function (v, r, i) {
                return formatMoneyFourWei(v);
            }, align:'right'},
            {field:'xsje', title:'销售金额', width:150, formatter:function (v, r, i) {
                return formatMoneyFourWei(v);
            }, align:'right'},
            {field:'ykje', title:'盈亏金额', width:150, formatter:function (v, r, i) {
                return formatMoneyFourWei(v);
            }, align:'right'}
        ]
    ];

    var grid = $('#ykbb_grid').datagrid({
        url:$.webPath() + '/tjbb/ykbb/ykbblist',
        toolbar:"#ykbb_toolbar",
        pagination:true,
        rownumbers:true,
        singleSelect:true,
        collapsible:true,
        fit:true,
        fitColumns:true,
        pageNumber:1,
        showFooter:true,
        onLoadSuccess:function () {
            $(".datagrid-htable .datagrid-cell").css('text-align', 'center');
        },
        columns:columns
    });
});
